#include<stdio.h>
#include<string.h>

int main()
{
	int sign,flag,key=1,i=0;
	char c[201]={'\0'},command[201]={'\0'},z[2]={'\0'};
	gets(c);
	do
	{
		char t[201]={'\0'};
		key=0;
		i=0;
		for(sign=0;sign<strlen(t);sign++)
		{
			t[sign]='\0';
		}
		gets(command);
		if(strcmp(c,"/")==0) i=1;
		if(strcmp(command,"cd /")==0&&i==0) strcpy(c,"/");
		else if(strcmp(command,"cd ..")==0)
		{
			if(i==0)
			{
				for(sign=strlen(c)-1;;sign--)
				{
					if(c[sign]!='/') c[sign]='\0';
					if(c[sign]=='/')
					{
						if(sign!=0) c[sign]='\0';
						break;
					}
				}
			}
		}
		else if(strncmp(command,"cd /",4)==0&&strlen(command)>4)
		{
			for(flag=3;flag<strlen(command);flag++)
			{
				t[key++]=command[flag];
			}
			strcpy(c,t);
		}
		else if(strncmp(command,"cd ",3)==0&&strlen(command)>4)
		{
			if(i!=1)
			{
				key=1;
				t[0]='/';
			}
			for(flag=3;flag<strlen(command);flag++)
			{
				t[key++]=command[flag];
			}
			strcat(c,t);
		}
		//printf("	");
		//puts(c);
	}while(strcmp(command,"pwd"));
	puts(c);
	return 0;
}
